package com.blast.comicsisland.model.commic.commiccatalog;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by dell on 2015/6/24.
 */
public class Info {
    //字段名 bookPartList
    private List<BookPart> bookPartList;
    private String totalpart;
    //字段名 partVersion
    private String partVersion;

    public List<BookPart> getBookPartList() {
        return bookPartList;
    }

    public void setBookPartList(List<BookPart> bookPartList) {
        this.bookPartList = bookPartList;
    }

    public String getTotalpart() {
        return totalpart;
    }

    public void setTotalpart(String totalpart) {
        this.totalpart = totalpart;
    }

    public String getPartVersion() {
        return partVersion;
    }

    public void setPartVersion(String partVersion) {
        this.partVersion = partVersion;
    }

    //-------------------------------->
    //解析
    public void jsonParse(JSONObject jsonObject){
        if (bookPartList == null) {
            bookPartList = new LinkedList<>();
        }
        if (jsonObject != null) {
            try {
                JSONArray jsonArr = jsonObject.getJSONArray("bookPartList");
                for (int i = 0; i < jsonArr.length(); i++) {
                    JSONObject infoObject = jsonArr.getJSONObject(i);
                    BookPart bookPart = new BookPart();
                    bookPart.jsonParse(infoObject);
                    bookPartList.add(bookPart);
                }
                partVersion = jsonObject.getString("partVersion");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

}
